import { potr } from "./seting/ds.js";

import Koa from 'koa'
import Router from 'koa-router'

let app = new Koa();
let router = new Router();

app.use(async(ctx,next)=>{

    let head = ctx.headers['x-auth-token']
    
    let vaule = `valid-token-123`;

    if(head && head === vaule){
        ctx.body = '11111';
    }else{
        ctx.status = 404;
        ctx.body = {
            "error": "Unauthorized",
            "message": "Invalid or missing token"
        }
    }
})

app.use(router.routes()).use(router.allowedMethods())

app.listen(potr,()=>{
    console.log(`http://localhost:${potr}`)
})